package com.smedi.ismedi.constructionproject.core.application.service.impl;

import com.smedi.ismedi.constructionproject.core.application.command.BidSectionCommand;
import com.smedi.ismedi.constructionproject.core.application.service.BidSectionApplicationService;
import com.smedi.ismedi.constructionproject.core.domain.aggregatemodel.BidSection;
import com.smedi.ismedi.constructionproject.core.domain.service.BidSectionDomainService;
import com.smedi.ismedi.web.starter.util.DozerUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: xulinjun
 * @Date: 2021-6-22 14:20
 */
@Slf4j
@Service
@AllArgsConstructor
public class BidSectionApplicationServiceImpl implements BidSectionApplicationService {
    private final DozerUtil dozerUtil;

    private final BidSectionDomainService bidSectionDomainService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public BidSection saveBidSectionInfo(BidSectionCommand bidSectionCommand) {
        BidSection bidSection = dozerUtil.convertor(bidSectionCommand, BidSection.class);
        return bidSectionDomainService.saveInfo(bidSection);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteBidSection(Long bidSectionId) {
        bidSectionDomainService.deleteInfo(bidSectionId);
    }

    @Override
    public Boolean checkProjectOrgBeUsedInBidSection(Long projectOrgId) {
        return bidSectionDomainService.checkProjectOrgBeUsedInBidSection(projectOrgId);
    }
}
